#include <iostream>
#include <vector>
using std::cout;
using std::endl;

//仅在栈上创建对象
class Point {
public:
    Point(int x,int y)
    :_x(x)
    ,_y(y) 
    {
    }

    void print(){
        cout<<"("<<_x<<","<<_y<<")"<<endl;
    }

    void * operator new(size_t) =delete;
    void  operator delete(void*) =delete;

private:
    int _x;
    int _y;
};

void test1(){
    std::vector<Point> pi={Point(1,1),Point(2,2),Point(3,3)};
    for(auto &p:pi){
        p.print();
    }
}

void test2(){
    std::vector<Point> pi={Point(1,1),Point(2,2),Point(3,3)};
    auto it =pi.begin(); 
    while(it != pi.end()){
        it->print();
        it++;
    }
}

void test3(){
    std::vector<Point> pi={Point(1,1),Point(2,2),Point(3,3)};
    for(size_t i=0;i<pi.size();i++){
        pi[i].print();
    }
}
int main()
{

    test1();
    cout<<"-------------------"<<endl;
    test2();
    cout<<"-------------------"<<endl;
    test3();
    return 0;
}

